#include "widget.h"
#include "ui_widget.h"

#include <lusb0_usb.h>

#include <QDebug>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    //usb_set_debug(250);
    usb_init(); /* initialize the library */
    usb_find_busses(); /* find all busses */
    usb_find_devices(); /* find all connected devices */

    usb_get_device_list();
}

Widget::~Widget()
{
    delete ui;
}


void Widget::usb_get_device_list()
{
    struct usb_bus *bus;
    struct usb_device *dev;

    for (bus = usb_get_busses(); bus; bus = bus->next) {
        for (dev = bus->devices; dev; dev = dev->next) {
            /* for specified device
            if (dev->descriptor.idVendor == MY_VID
                        && dev->descriptor.idProduct == MY_PID)
            {
                return usb_open(dev);
            }
            */
            qDebug("VID:VID = %x:%x\n", dev->descriptor.idVendor, dev->descriptor.idProduct);

        }
    }

}
